//
//  HS_DetailCollectionReusableView.m
//  悦享
//
//  Created by 韩双 on 16/3/17.
//  Copyright © 2016年 张洪国. All rights reserved.
//

#import "HS_DetailCollectionReusableView.h"
#import <UIImageView+WebCache.h>

@interface HS_DetailCollectionReusableView ()

@property (nonatomic, retain) UIImageView *userImageView;   /**< 用户头像 */
@property (nonatomic, retain) UILabel *nameLable;  /**< 用户名 */
@property (nonatomic, retain) UILabel *conmentLable;   /**< title */
@property (nonatomic, retain) UILabel *categoryLable;   /**< 标签 */


@end

@implementation HS_DetailCollectionReusableView

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self createSubviews];
    }
    return self;
}
// 初始化
- (void)createSubviews {
    
    self.userImageView = [[UIImageView alloc] init];
    [self addSubview:_userImageView];
    
    self.nameLable = [[UILabel alloc] init];
    [self addSubview:_nameLable];
    
    self.conmentLable = [[UILabel alloc] init];
    [self addSubview:_conmentLable];
    
    self.categoryLable = [[UILabel alloc] init];
    [self addSubview:_categoryLable];
    
}

- (void)setModel:(HS_detailModle *)model {
    
    _model = model;
    
    [self assignment];
    
    
}

// 赋值
- (void)assignment {
    
    _userImageView.frame = CGRectMake(10, 10, 30, 30);
    _userImageView.layer.cornerRadius = 15;
    _userImageView.layer.masksToBounds = YES;
    [_userImageView sd_setImageWithURL:[NSURL URLWithString:_model.avatar_url] placeholderImage:[UIImage imageNamed:PLACE_HLODER]];
    
    
    _nameLable.frame = CGRectMake(50, 20, SREEN_WIDTH - 50, 20);
    _nameLable.font = [UIFont systemFontOfSize:15];
    _nameLable.text = _model.user_name;
    
    CGSize size = [APPTools labelRectWithSize:CGSizeMake(SREEN_WIDTH - 20, 0) LabelText:_model.content Font:[UIFont systemFontOfSize:17]];
    _conmentLable.numberOfLines = 1000;
    _conmentLable.frame = CGRectMake(10, 50, size.width, size.height);
    _conmentLable.text = _model.content;
    
    
    CGSize size2 = [APPTools labelRectWithSize:CGSizeMake(0, 20) LabelText:_model.category_name Font:[UIFont systemFontOfSize:13]];
    _categoryLable.frame = CGRectMake(10, size.height + 60, size2.width + 20, 20);
    _categoryLable.font = [UIFont systemFontOfSize:12];
    _categoryLable.layer.cornerRadius = 10;
    _categoryLable.layer.borderWidth = 1;
    _categoryLable.layer.borderColor = [UIColor blackColor].CGColor;
    _categoryLable.textAlignment = NSTextAlignmentCenter;
    _categoryLable.text = _model.category_name;
    
}

@end
